<?php
	/**
	*Author 雷日锦 362606856@qq.com 
	*控制器自动生成
	*/
	if(!defined("ROOT_PATH")) exit("die Access ");
	class shop_articleControl extends skymvc{
		public $userid;
		public $skins="shop/index/";
		public $shopdata;
		public function __construct(){
			parent::__construct();			
		}
		
		public function onInit(){
			$shopid=get_post("shopid","i");
			$this->shopdata=M("shop")->selectRow(array("where"=>" status<10 AND shopid=".$shopid));
			if(empty($this->shopdata)){
				$this->goall("店铺不存在或者被禁止了",1,0,"/index.php");
			}
			$this->smarty->assign(
				array(
				"shopskins"=>"shop/".$this->shopdata['tpl'],
				"shop"=>$this->shopdata
				)
			);
		}
		
		public function onDefault(){
			$where="";
			$url="/index.php?m=shop_article&a=default";
			$limit=20;
			$start=get("per_page","i");
			$option=array(
				"start"=>intval(get_post('per_page')),
				"limit"=>$limit,
				"order"=>" id DESC",
				"where"=>$where
			);
			$rscount=true;
			$data=M("shop_article")->select($option,$rscount);
			$pagelist=$this->pagelist($rscount,$limit,$url);
			$this->smarty->assign(
				array(
					"data"=>$data,
					"pagelist"=>$pagelist,
					"rscount"=>$rscount,
					"url"=>$url
				)
			);
			$this->smarty->display("shop_article/index.html");
		}
		
		public function onList(){
			$where="";
			$url="/index.php?m=shop_article&a=default";
			$limit=20;
			$start=get("per_page","i");
			$option=array(
				"start"=>intval(get_post('per_page')),
				"limit"=>$limit,
				"order"=>" id DESC",
				"where"=>$where
			);
			$rscount=true;
			$data=M("shop_article")->select($option,$rscount);
			$pagelist=$this->pagelist($rscount,$limit,$url);
			$this->smarty->assign(
				array(
					"data"=>$data,
					"pagelist"=>$pagelist,
					"rscount"=>$rscount,
					"url"=>$url
				)
			);
			$this->smarty->display("shop_article/index.html");
		}
		
		public function onShow(){
			$id=get_post("id","i");
			if($id){
				$data=M("shop_article")->selectRow(array("where"=>"id={$id}"));
				
			}
			$this->smarty->assign(array(
				"data"=>$data
			));
			$this->smarty->display("shop_article/show.html");
		}
		
	}

?>